﻿using System;
using Apworks;
using TinyForum.Infrastructure;

namespace TinyForum.Domain.Model
{
    /// <summary>
    /// Represents the base class for the forum contents such as
    /// posts and replies.
    /// </summary>
    public abstract class ContentBase : IEntity
    {
        #region Protected Fields
        protected string title;
        protected string content;
        protected DateTime dateCreated;
        protected DateTime? dateModified;
        protected long userID;
        #endregion

        #region Public Properties
        /// <summary>
        /// Gets or sets the title of the post or reply.
        /// </summary>
        public virtual string Title
        {
            get { return this.title; }
            set { this.title = value; }
        }
        /// <summary>
        /// Gets or sets the content of the post or reply.
        /// </summary>
        public virtual string Content
        {
            get { return this.content; }
            set { this.content = value; }
        }
        /// <summary>
        /// Gets or sets the date on which the post or reply was created.
        /// </summary>
        public virtual DateTime DateCreated
        {
            get { return this.dateCreated; }
            set { this.dateCreated = value; }
        }
        /// <summary>
        /// Gets or sets the date on which the post or reply was modified.
        /// </summary>
        public virtual DateTime? DateModified
        {
            get { return this.dateModified; }
            set { this.dateModified = value; }
        }
        /// <summary>
        /// Gets or sets the ID of the user who submitted the post or reply.
        /// </summary>
        public virtual long UserID
        {
            get { return this.userID; }
            set { this.userID = value; }
        }
        #endregion

        #region IEntity Members
        /// <summary>
        /// Gets or sets the ID of the post or reply.
        /// </summary>
        public virtual long ID { get; set; }

        #endregion

        #region IEquatable<IEntity> Members
        /// <summary>
        /// Checks if the given entity is equal to the current
        /// post or reply instance.
        /// </summary>
        /// <param name="other">The given entity to be checked.</param>
        /// <returns>True if the two are identical, otherwise, false.</returns>
        public virtual bool Equals(IEntity other)
        {
            return this.CheckEquality(other);
        }

        #endregion
    }
}
